package defaulPackage;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

import estrategia_Marcos.LimitFile;

public class Profile {
	private String nick;
	private int phone;
	private Instrument instrument;
	private Style style;
	private List<File> files;
	private List<Profile> friends;
	private LimitFile limitFile;

	public Profile(String nick, int phone, Instrument instrument, Style style) {
		this.nick = nick;
		this.instrument = instrument;
		this.style = style;
		this.phone = phone;
		friends = new LinkedList<Profile>();
		files = new LinkedList<File>();
	}
	
	public void addFriend(Profile profile){
		friends.add(profile);
	}
	
	 public void setLimitFile(LimitFile limit) {
		this.limitFile = limit;
	}
	
	public void addFile(File file){
		if (limitFile.addFile(file, files)){
			files.add(file);
		}
	}
	
	public void pay(){
		limitFile.pay();
	}

	public void removeFile(File file) {
		for (int x = 0; x < files.size(); x++) {
			if (file.match(files.get(x))) {
				System.out.println("Arquivo removido com sucesso!");
				files.remove(x);
				break;
			}
		}
	}

	public void removeFriend(Profile profile) {
		for (int x = 0; x < friends.size(); x++) {
			if (profile.match(friends.get(x))) {
				System.out.println("Amigo removido com sucesso!");
				friends.remove(x);
				break;
			}
		}
	}
	
	public List<Profile> getFriends() {
		return friends;
	}
	
	public List<File> search(File file){
		List<File> search = new ArrayList<File>();
		for (File f: files){
			if (file.match(f)){
				search.add(f);
			}
		}
		return search;
	}

	public List<File> getMusics(){
		List<File> musics = new LinkedList<File>();
		for(File file: files){
			if (file instanceof Music){
				musics.add(file);
			}
		}
		return musics;
	}
	
	public List<File> getPhotos() {
		List<File> photos = new LinkedList<File>();
		for(File file: files){
			if (file instanceof Photo){
				photos.add(file);
			}
		}
		return photos;
	}
	
	public List<File> getVideos() {
		List<File> videos = new LinkedList<File>();
		for(File file: files){
			if (file instanceof Video){
				videos.add(file);
			}
		}
		return videos;
	}

	public String getNick() {
		return nick;
	}

	public Instrument getInstrument() {
		return instrument;
	}

	public Style getStyle() {
		return style;
	}

	public int getPhone() {
		return phone;
	}

	public void setNick(String nick) {
		this.nick = nick;
	}

	public void setPhone(int phone) {
		this.phone = phone;
	}

	public void setInstrument(Instrument instrument) {
		this.instrument = instrument;
	}

	public void setStyle(Style style) {
		this.style = style;
	}

	public boolean match(Profile profile) {
		if (!nick.equals(profile.getNick()))
			return false;
		if (!instrument.equals(profile.getInstrument()))
			return false;
		if (!style.equals(profile.getStyle()))
			return false;
		return true;
	}

}
